<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>&#39;Config Files&#39;</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51822 BLE SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__ble__sdk__apps__config__files.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">'Config Files'</div>  </div>
<div class="ingroups"><a class="el" href="group__ble__sdk__apps.html">Example Applications</a></div></div>
<div class="contents">
<p>Applications will normally need one or two configuration files:</p>
<h2><a class="anchor" id="config_file_app_timer_cfg"></a>
Timer configuration file</h2>
<p>All applications using the <a class="el" href="group__app__timer.html">Application Timer</a> module must have a configuration file named app_timer_cfg.h. Here is an example of this <a href="file:">file:</a></p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#ifndef APP_TIMER_CFG_H__</span>
<span class="preprocessor"></span><span class="preprocessor">#define APP_TIMER_CFG_H__</span>
<span class="preprocessor"></span>
<span class="preprocessor">#define APP_TIMER_FREQ  1000</span>
<span class="preprocessor"></span>
<span class="keyword">typedef</span> <span class="keyword">enum</span> 
{
    APP_TIMER_BATTERY_LEVEL_MEAS,
    APP_TIMER_CONN_PARAMS,
    APP_TIMER_LAST_ELEMENT
} app_timer_id_t;

<span class="preprocessor">#endif // APP_TIMER_CFG_H__</span>
</pre></div><p>APP_TIMER_FREQ is the preferred frequency of the RTC1 counter (which is used to implement the <a class="el" href="group__app__timer.html">Application Timer</a>). This value is used to compute the RTC clock prescaler, using the formula</p>
<div class="fragment"><pre class="fragment">
RTC_CLOCK_FREQ = 32768
RTC_PRESCALER  = (RTC_CLOCK_FREQ / APP_TIMER_FREQ) - 1
</pre></div><p>The result is rounded to the closest integer.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>As the RTC clock frequency is 32768, the actual counter frequency may not be identical to the frequency set in this constant. The <a class="el" href="group__app__timer.html">Application Timer</a> will try to compensate for this inside the <a class="el" href="group__app__timer.html#ga54651d3dc5266bd7541b80918527b060" title="Starts a timer.">app_timer_start()</a> function.</dd></dl>
<p>app_timer_cfg.h must also contain a app_timer_id_t enum, containing one entry for each timer to be used in the application. If the application is using the <a class="el" href="group__ble__sdk__lib__conn__params.html">Connection Parameters Negotiation</a> module, app_timer_id_t must also contain APP_TIMER_CONN_PARAMS. The last entry in app_timer_id_t must always be APP_TIMER_LAST_ELEMENT.</p>
<h2><a class="anchor" id="config_file_app_scheduler_cfg"></a>
Scheduler configuration file</h2>
<p>If the application is using the <a class="el" href="group__app__scheduler.html">Scheduler</a>, it must also have a configuration file named app_scheduler_cfg.h. Here is an example of this <a href="file:">file:</a></p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#ifndef APP_SCHEDULER_CFG_H__</span>
<span class="preprocessor"></span><span class="preprocessor">#define APP_SCHEDULER_CFG_H__</span>
<span class="preprocessor"></span>
<span class="preprocessor">#include &quot;ble.h&quot;</span>
<span class="preprocessor">#include &quot;<a class="code" href="app__timer_8h.html">app_timer.h</a>&quot;</span>

<span class="preprocessor">#define APP_SCHED_QUEUE_NUM       2</span>
<span class="preprocessor"></span><span class="preprocessor">#define APP_SCHED_QUEUE_SIZE      10</span>
<span class="preprocessor"></span>
<span class="preprocessor">#define APP_SCHED_QUEUE_HIGH_PRI  0</span>
<span class="preprocessor"></span><span class="preprocessor">#define APP_SCHED_QUEUE_LOW_PRI   1</span>
<span class="preprocessor"></span>
<span class="keyword">typedef</span> <span class="keyword">enum</span> 
{
    APP_SCHED_EVENT_BLE,
    APP_SCHED_EVENT_TIMER,
    APP_SCHED_EVENT_MOUSE
} app_sched_event_id_t;

<span class="keyword">typedef</span> <span class="keyword">struct</span>
{
    app_sched_event_id_t event_id;
    <span class="keyword">union </span>
    {
        <span class="keyword">struct</span>
        {
            <a class="code" href="structble__evt__t.html" title="Common BLE Event type, wrapping the module specific event reports.">ble_evt_t</a> ble_evt;
        } ble;
        <span class="keyword">struct</span>
        {
            app_timer_id_t              timer_id;
            <a class="code" href="group__app__timer.html#ga0586b27407494731cad5b72b12aa5bfe" title="Application timeout handler type.">app_timer_timeout_handler_t</a> timeout_handler;
        } timer;
        <span class="keyword">struct</span>
        {
            int16_t x_delta;
            int16_t y_delta;
        } mouse;
    } data;
} app_sched_event_data_t;

<span class="preprocessor">#endif // APP_SCHEDULER_CFG_H__</span>
</pre></div><p>The <a class="el" href="group__app__scheduler.html">Scheduler</a> can be configured to use several event queues, each with a different event priority level. When it is executing events, all events in a higher priority queue are executed before executing any events in a lower level queue, disregarding the time that the events were generated.</p>
<p>APP_SCHED_QUEUE_NUM defines the number of queues, and APP_SCHED_QUEUE_SIZE is the maximum number of events in each queue. Also, each priority level should have a corresponding constant in app_scheduler_cfg.h. The highest priority is 0, the second highest is 1 and so on.</p>
<p>The app_sched_event_id_t enum must contain an id for each event type to be used by the application. For handling BLE events, APP_SCHED_EVENT_BLE must be present in the enum. If the application is using app_timer, app_sched_event_id_t must contain APP_SCHED_EVENT_TIMER. Apart from these, app_sched_event_id_t may be modified according to application requirements.</p>
<p>The file must also define app_sched_event_data_t, which is used for holding <a class="el" href="group__app__scheduler.html">Scheduler</a> events, including the corresponding event data. For each event type that is able to transfer data, there will be a corresponding entry in the data union. If APP_SCHED_EVENT_BLE and/or APP_SCHED_EVENT_TIMER are included in app_sched_event_id_t, the ble and/or timer parts must be included in app_sched_event_data_t.</p>
<h2><a class="anchor" id="config_file_ble_bondmngr_cfg"></a>
Bond Manager configuration file</h2>
<p>Application using the <a class="el" href="group__ble__sdk__lib__bond__manager.html">Bonds and Persistent Data Manager</a> must have a configuration file named <a class="el" href="ble__bondmngr__cfg_8h_source.html">ble_bondmngr_cfg.h</a>. Here is an example of this <a href="file:">file:</a></p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#ifndef BLE_BONDMNGR_CFG_H__</span>
<span class="preprocessor"></span><span class="preprocessor">#define BLE_BONDMNGR_CFG_H__</span>
<span class="preprocessor"></span>
<span class="preprocessor">#define BLE_BONDMNGR_CCCD_COUNT          1</span>
<span class="preprocessor"></span><span class="preprocessor">#define BLE_BONDMNGR_MAX_BONDED_MASTERS  4</span>
<span class="preprocessor"></span>
<span class="preprocessor">#endif // BLE_BONDMNGR_CFG_H__</span>
</pre></div><p>BLE_BONDMNGR_CCCD_COUNT is the number of CCCDs used in the application, and BLE_BONDMNGR_MAX_BONDED_MASTERS is the maximum number of bonded masters to be supported by the application. </p>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
